var scrollFlag;
// /初始化地图
function initMap(url,paramsData){
    map.clearOverlays();//清除所有地图覆盖物
    RequestData (url,paramsData);
    if(allMapData.length==0 || mapDataStatus==false){
        return
    }
    if(paramsData["currentMap"] == "heatMap"){
        createHeat(allMapData);
    }
    else if(paramsData["currentMap"] == "clusterMap"){
        createDistrict(allMapData);
    }
    else if(paramsData["currentMap"] == "pointMap"){
        createPoint(allMapData);
    }
    else if(paramsData["currentMap"] == "aroundAccountMap"){
        createAccountProvince(allMapData);
    }

}
//热力图覆盖物
function createHeat(mapDataList){
    var points = mapDataList;
    heatOverlays = new BMapLib.HeatmapOverlay({"radius":20});
    map.addOverlay(heatOverlays);
    heatOverlays.setDataSet({data:points,max:8});
    if(!isSupportCanvas()){
        alert('热力图目前只支持有canvas支持的浏览器,您所使用的浏览器不能使用热力图功能~')
    }
    scrollFlag = true;
}
//散点图覆盖物
function createPoint(mapDataList){
    var pt = null;
    var markers = [];
    var i = 0;
    for (; i < mapDataList.length; i++) {
        if (mapDataList[i].lng && mapDataList[i].lat) {
            pt = new BMap.Point(mapDataList[i].lng, mapDataList[i].lat);
            markers.push(new BMap.Marker(pt));
        }

    }
    pointOverlays = new BMapLib.MarkerClusterer(map, {markers:markers});
    scrollFlag = true;
}
//网点周边地图覆盖物
function createSurrounding(mapDataList){
    var pt = null;
    var markers = [];
    var i = 0;
    for (; i < mapDataList.length; i++) {
        if (mapDataList[i].lng && mapDataList[i].lat) {
            pt = new BMap.Point(mapDataList[i].lng, mapDataList[i].lat);
            markers.push(new BMap.Marker(pt));
        }

    }
    pointOverlays = new BMapLib.MarkerClusterer(map, {markers:markers});
    scrollFlag = true;
}
//行政区覆盖物
function createDistrict(mapDataList){
    mapDataList.forEach(function (data) {
        //自定义覆盖物
        function ComplexCustomOverlay(point, text,num){
            this._point = point;
            this._text = text;
            this._num = num;
        }
        ComplexCustomOverlay.prototype = new BMap.Overlay();
        ComplexCustomOverlay.prototype.initialize = function(map){
            this._map = map;
            var div = this._div = document.createElement("div");
            div.style.position = "absolute";
            div.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
            div.style.color = "white";
            div.style.height = "80px";
            div.style.width = "80px";
            div.style.lineHeight = "62px";
            div.style.opacity = '0.9';
            div.style.textAlign = "center";
            div.style.borderRadius = "50%";
            div.style.whiteSpace = "nowrap";
            div.style.MozUserSelect = "none";
            div.style.fontSize = "12px";
            div.style.cursor = "pointer";
            if(parseInt(this._num) < 300){
                div.style.backgroundColor = "#79ecd6";
            }else if(parseInt(this._num) >=300 && parseInt(this._num) < 500) {
                div.style.backgroundColor = "#4cdcc0";
            }else if(parseInt(this._num) >=500 && parseInt(this._num) < 700) {
                div.style.backgroundColor = "#33c3a7";
            }else {
                div.style.backgroundColor = "#26b095";
            }
            var span = this._span = document.createElement("span");
            div.appendChild(span);
            span.appendChild(document.createTextNode(this._text));
            //var that = this;
            var arrow = this._arrow = document.createElement("p");
            arrow.style.position = "absolute";
            arrow.style.width = "11px";
            arrow.style.height = "10px";
            arrow.style.top = "22px";
            arrow.style.left = "29%";
            div.appendChild(arrow);
            arrow.appendChild(document.createTextNode(this._num));
            var ply = [];
            var status;
            div.onmouseenter = function(){
                //pay = [];
                status = true;
                this.style.backgroundColor = "#e84a01";
                var bdary = new BMap.Boundary();

                bdary.get(data.name, function(rs){       //获取行政区域
                    //map.removeOverlay(ply);
                    var count = rs.boundaries.length; //行政区域的点有多少个
                    if (count === 0) {
                        alert('未能获取当前输入行政区域');
                        return ;
                    }
                    var pointArray = [];
                    for (var i = 0; i < count; i++) {
                        var p = new BMap.Polygon(rs.boundaries[i],  {strokeColor:"#e84a01", strokeWeight:4, strokeOpacity:0.0, fillOpacity: 0.0, fillColor: "none"}); //建立多边形覆盖物
                        if(status == true){
                            map.addOverlay(p);  //添加覆盖物
                        }

                        pointArray = pointArray.concat(p.getPath());
                        ply.push(p)
                    }
                });
            };
            div.onmouseleave = function(){
                if(parseInt(this.children[1].innerText) < 300){
                    div.style.backgroundColor = "#79ecd6";
                }else if(parseInt(this.children[1].innerText) >=300 && parseInt(this.children[1].innerText) < 500) {
                    div.style.backgroundColor = "#4cdcc0";
                }else if(parseInt(this.children[1].innerText) >=500 && parseInt(this.children[1].innerText) < 700) {
                    div.style.backgroundColor = "#33c3a7";
                }else {
                    div.style.backgroundColor = "#26b095";
                }
                status = false;
                var p;
                while(p = ply.pop()){
                    map.removeOverlay(p);
                }
            };
            div.onclick = function() {
                scrollFlag = false;
                flag = true;
                map.clearOverlays();
                var zone_number = {city:$("#city").val(),district:data.zoneNumber};
                RequestData(communityUrl,zone_number);
                if(allMapData.length==0 || mapDataStatus==false){
                    return
                }
                map.centerAndZoom(new BMap.Point(allMapData[0].lng, allMapData[0].lat),16);
                createCommunity(allMapData);
                searchCommunityResult("searchCommunity",allMapData);
            };

            map.getPanes().labelPane.appendChild(div);

            return div;
        };
        ComplexCustomOverlay.prototype.draw = function(){
            var map = this._map;
            var pixel = map.pointToOverlayPixel(this._point);
            this._div.style.left = pixel.x - parseInt(this._arrow.style.left) + "px";
            this._div.style.top  = pixel.y - 30 + "px";
        };
        var pt = new BMap.Point(data.lng,data.lat);
        var count = data.count + "笔";
        myCompOverlay = new ComplexCustomOverlay(pt, data.name, count);
        map.addOverlay(myCompOverlay);
    });
    scrollFlag = true;
}
//小区覆盖物
function createCommunity (paramsData) {
    paramsData.forEach(function (Community) {
        //自定义小区覆盖物
        function ComplexCustomOverlay(point, text,num){
            this._point = point;
            this._text = text;
            this._num = num;
        }
        ComplexCustomOverlay.prototype = new BMap.Overlay();
        ComplexCustomOverlay.prototype.initialize = function(map){
            this._map = map;
            var div = this._div = document.createElement("div");
            div.style.position = "absolute";
            div.style.backgroundColor = "#26b095";
            div.style.color = "white";
            div.style.height = "60px";
            div.style.width = "60px";
            div.style.textAlign = "center";
            div.style.borderRadius = "50%";
            div.style.whiteSpace = "nowrap";
            div.style.MozUserSelect = "none";
            div.style.fontSize = "12px";
            div.style.cursor = "pointer";
            div.style.zIndex = "-11";
            if(this._num < 5){
                div.style.backgroundColor = "#79ecd6";
            }else if(this._num >= 5 && this._num < 10) {
                div.style.backgroundColor = "#4cdcc0";
            }else if(this._num >= 10 && this._num < 15) {
                div.style.backgroundColor = "#33c3a7";
            }else {
                div.style.backgroundColor = "#26b095";
            }
            var cont = document.createElement("div");
            cont.style.marginTop = "20%";
            var span = this._span = document.createElement("p");
            span.appendChild(document.createTextNode("笔"));
            span.style.margin = "0";
            //var that = this;
            var arrow = this._arrow = document.createElement("p");
            arrow.style.left = "17px";
            arrow.style.margin = "0";
            cont.appendChild(arrow);
            cont.appendChild(span);
            div.appendChild(cont);
            var message = document.createElement("div");
            message.style.width = "160px";
            message.style.height = "50px";
            message.style.background = "#FFFFFF";
            message.style.opacity = ".8";
            message.style.borderTopRightRadius = "25px";
            message.style.borderBottomRightRadius = "25px";
            message.style.position = "absolute";
            message.style.top = "5px";
            message.style.zIndex = "-10";
            message.style.color = "#666666";
            message.style.lineHeight = "50px";
            message.style.display = "none";
            message.style.textAlign = "center";
            message.style.border = "1px solid #e84a01";
            message.style.boxSizing = "border-box";
            message.style.left = "40px";
            message.style.fontSize = "14px";
            message.style.boxShadow = "0 0 6px #092923";
            message.appendChild(document.createTextNode(this._text));
            div.appendChild(message);
            arrow.appendChild(document.createTextNode(this._num));

            div.onmouseenter = function(){
                this.style.backgroundColor = "#e84a01";
                message.style.display = "block";
                this.style.zIndex = "auto";
                message.style.zIndex = "-10";
            };
            div.onmouseleave = function(){
                //this.style.backgroundColor = "#26b095";
                if(this.children[0].children[0].innerText < 5){
                    div.style.backgroundColor = "#79ecd6";
                }else if(this.children[0].children[0].innerText >= 5 && this.children[0].children[0].innerText < 10) {
                    div.style.backgroundColor = "#4cdcc0";
                }else if(this.children[0].children[0].innerText >= 10 && this.children[0].children[0].innerText < 15) {
                    div.style.backgroundColor = "#33c3a7";
                }else {
                    div.style.backgroundColor = "#26b095";
                }
                message.style.display = "none";
                this.style.zIndex = "-11";
            };
            div.onclick = function() {
                scrollFlag = false;
                map.clearOverlays();
                var inputData = getInputData();
                inputData.communityId=Community.communityId;
                if(currentMap=="clusterMap"){
                    RequestData("/map/mapBuildingBankData",inputData);
                }else{
                    RequestData(buildingUrl,inputData);
                }

                map.centerAndZoom(new BMap.Point(Community.lng, Community.lat),19);

                if(currentMap=="clusterMap"){
                    createBuilding_bank(allMapData,boundaryData,pt,"abc.png",Community.communityName,Community.communityId);
                }else{
                    createBuilding(allMapData,map);
                    searchBuildingResult("searchCommunity",allMapData);
                }

            };

            map.getPanes().labelPane.appendChild(div);
            return div;
        };
        ComplexCustomOverlay.prototype.draw = function(){
            var map = this._map;
            var pixel = map.pointToOverlayPixel(this._point);
            this._div.style.left = pixel.x - parseInt(this._arrow.style.left) + "px";
            this._div.style.top  = pixel.y - 30 + "px";
        };
        var pt = new BMap.Point(Community.lng,Community.lat);
        myCompOverlay = new ComplexCustomOverlay(pt, Community.communityName, Community.count);
        map.addOverlay(myCompOverlay);
    });
    scrollFlag = true;
}
//楼栋覆盖物
function createBuilding(paramsData,topmap){
    var target,topDiv,sj,lastSmall,oneSmall;
    paramsData.forEach(function (searchEstate) {
        searchEstate.forEach(function (data,i){
            //自定义楼栋覆盖物
            function ComplexCustomOverlay(point,num){
                this._point = point;
                this._num = num;
            }
            ComplexCustomOverlay.prototype = new BMap.Overlay();
            ComplexCustomOverlay.prototype.initialize = function(map){
                this._map = map;
                var smallDiv;
                if(i != 0){
                    if(oneSmall) oneSmall.style.padding = "6px 18px 6px 10px";
                    smallDiv = document.createElement('div');
                    smallDiv.appendChild(document.createTextNode(this._num));
                    smallDiv.style.padding = "6px 18px 6px 10px";
                    smallDiv.style.borderRadius = '8px';
                    smallDiv.style.marginLeft = '-10px';
                    if(data.estateList[0].define == '中风险'){
                        smallDiv.style.backgroundColor = "#FF9800";
                    }else if(data.estateList[0].define == '低风险'){
                        smallDiv.style.backgroundColor = "#62CB31";
                    }else if(data.estateList[0].define == '高风险'){
                        smallDiv.style.backgroundColor = "#E51C23";
                    }else if(data.estateList[0].define == '亏损'){
                        smallDiv.style.backgroundColor = "#8B1818";
                    }
                    lastSmall = smallDiv;
                    topDiv.appendChild(smallDiv);
                }else {
                    if(lastSmall) lastSmall.style.padding = '6px 10px';
                    var div = this._div = document.createElement("div");
                    div.style.position = "absolute";
                    div.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
                    div.style.color = "white";
                    div.style.opacity = '0.95';
                    div.style.display = 'flex';
                    div.style.whiteSpace = "nowrap";
                    div.style.MozUserSelect = "none";
                    div.style.fontSize = "12px";
                    div.style.cursor = "pointer";
                    smallDiv = document.createElement('div');
                    smallDiv.appendChild(document.createTextNode(this._num));
                    smallDiv.style.padding = "6px 10px";
                    smallDiv.style.borderRadius = "8px";
                    div.appendChild(smallDiv);
                    sj = this._p = document.createElement("p");
                    if(data.estateList[0].define == '中风险'){
                        smallDiv.style.backgroundColor = "#FF9800";
                        sj.style.borderTop = "10px solid #FF9800";
                    }else if(data.estateList[0].define == '低风险'){
                        smallDiv.style.backgroundColor = "#62CB31";
                        sj.style.borderTop = "10px solid #62CB31";
                    }else if(data.estateList[0].define == '高风险'){
                        smallDiv.style.backgroundColor = "#E51C23";
                        sj.style.borderTop = "10px solid #E51C23";
                    }else if(data.estateList[0].define == '亏损'){
                        smallDiv.style.backgroundColor = "#8B1818";
                        sj.style.borderTop = "10px solid #8B1818";
                    }
                    sj.style.position = "absolute";
                    sj.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
                    sj.style.width = 0;
                    sj.style.height = 0;
                    sj.style.borderLeft = "10px solid transparent";
                    sj.style.borderRight = "10px solid transparent";
                    sj.style.bottom = "-20px";
                    sj.style.left = '6px';
                    div.appendChild(sj);
                    oneSmall = smallDiv;
                    lastSmall = null;
                    topDiv = div;
                }
                topDiv.onclick = function () {
                    $(this).siblings("div").children("div.row").css("display","none");
                    $(this).siblings("div").css('zIndex','-11');
                    $(this).css('zIndex','11')
                    $(this).children('div.row').toggle();
                    if($(this).children('div.row').length >= 1) return;
                    var listDiv = document.createElement("div");
                    listDiv.style.position = 'absolute';
                    listDiv.style.left = this.offsetWidth + 14 + "px";
                    listDiv.style.color = '#6a6c6f';
                    listDiv.style.width = '400px';
                    listDiv.style.whiteSpace = 'normal';
                    listDiv.className = 'row';
                    var col = document.createElement("div");
                    var hpanel = document.createElement("div");
                    hpanel.className = 'hpanel';
                    var hpanelHead = document.createElement("div");
                    hpanelHead.className = 'panel-heading hbuilt';
                    hpanelHead.onclick = function (e) {
                        e.stopPropagation()
                    };
                    listDiv.onmouseenter = function () {
                        topmap.disableScrollWheelZoom();
                    };
                    listDiv.onmouseleave = function () {
                        topmap.enableScrollWheelZoom();
                    };
                    var panelTools = document.createElement('div');
                    panelTools.className = 'panel-tools';
                    var closebox = document.createElement('a');
                    var closeIcon = document.createElement('i');
                    closeIcon.className = 'fa fa-times';
                    closebox.appendChild(closeIcon);
                    closebox.className = 'closebox';
                    var that = $(this);
                    closebox.onclick = function () {
                        that.children("div.row").css("display","none");
                    };
                    panelTools.appendChild(closebox);
                    hpanelHead.appendChild(panelTools);
                    hpanelHead.appendChild(document.createTextNode(data.estateList[0].communityname));
                    var hpanelBody = document.createElement("div");
                    hpanelBody.className = 'panel-body no-padding';
                    hpanelBody.style.maxHeight = '190px';
                    hpanelBody.style.overflowY = 'auto';
                    var listGroup = document.createElement('ul');
                    listGroup.className = 'list-group';
                    var hpanelFoot = document.createElement('div');
                    hpanelFoot.className = 'panel-footer';
                    hpanelBody.appendChild(listGroup);
                    hpanel.appendChild(hpanelHead);
                    hpanel.appendChild(hpanelBody);
                    hpanel.appendChild(hpanelFoot);
                    col.appendChild(hpanel);
                    listDiv.appendChild(col);
                    this.appendChild(listDiv);
                    searchEstate.forEach(function(data){
                        var itemData = data.estateList;
                        itemData.forEach(function (data) {
                            var item = document.createElement('li');
                            item.className = 'list-group-item ';
                            var badge = document.createElement('span');
                            badge.className = 'badge badge-info';
                            badge.innerHTML = data.cltv + '%';
                            item.appendChild(badge);
                            if(data.define == '中风险'){
                                badge.style.backgroundColor = "#FF9800";
                            }else if(data.define == '低风险'){
                                badge.style.backgroundColor = "#62CB31";
                            }else if(data.define == '高风险'){
                                badge.style.backgroundColor = "#E51C23";
                            }else if(data.define == '亏损'){
                                badge.style.backgroundColor = "#8B1818";
                            }
                            item.appendChild(document.createTextNode(data.sourceaddress));
                            item.onclick = function () {
                                var href = window.location.origin + "/estate/mapShow/" + data.id;
                                window.open(href);
                            };
                            listGroup.appendChild(item);
                        });
                    });
                    var listLength = listGroup.children.length;
                    hpanelFoot.innerHTML = '共 '+listLength+' 笔';
                };
                map.getPanes().labelPane.appendChild(topDiv);
                return topDiv;
            };
            ComplexCustomOverlay.prototype.draw = function(){
                var map = this._map;
                var pixel = map.pointToOverlayPixel(this._point);
                if(i != 0){
                    topDiv.style.left = pixel.x + (i * target -1) + "px";
                }else {
                    target = this._div.offsetWidth;
                    topDiv.style.left = pixel.x + "px";
                }
                topDiv.style.top  = pixel.y + "px";
            };
            var pt = new BMap.Point(data.estateList[0].lng,data.estateList[0].lat);
            var areaResult = data.estateList.length + "笔";
            myCompOverlay = new ComplexCustomOverlay(pt, areaResult);
            map.addOverlay(myCompOverlay);
        });
    });
    scrollFlag = true;
}
//银行楼栋覆盖物
function createBuilding_bank (paramsData,boundaryData,lineCenter,logo,cityName,accountId) {
    //自定义边界线和中心点图标
    boundaryData.forEach(function(data){
        var line = new BMap.Polygon(data.coordinates,  {strokeColor:"#e84a01", strokeWeight:4, strokeOpacity:0.0, fillOpacity: 0.0, fillColor: "none"}); //建立多边形覆盖物
        map.addOverlay(line);
    });
    function ComplexCustomOverlay(point,text,name){
        this._point = point;
        this._text = text;
        this._name = name;
    }
    ComplexCustomOverlay.prototype = new BMap.Overlay();
    ComplexCustomOverlay.prototype.initialize = function(map){
        this._map = map;
        var div = this._div = document.createElement("div");
        var img = document.createElement('img');
        img.src = '/assets/accountLogo/zhoubian.png';
        div.style.position = "absolute";
        div.style.cursor = 'pointer';
        div.style.zIndex = '1';
        var message = document.createElement('div');
        var collateral = document.createElement('div');
        var icon = document.createElement('img');
        icon.src = '/assets/accountLogo/isiconT.png';
        icon.style.padding = '0 4px 4px 4px';
        collateral.appendChild(icon);
        collateral.appendChild(document.createTextNode('未押品'));
        var iscollateral = document.createElement('div');
        var isicon = document.createElement('img');
        isicon.src = '/assets/accountLogo/iconT.png';
        isicon.style.padding = '0 4px 4px 4px';
        iscollateral.appendChild(isicon);
        iscollateral.appendChild(document.createTextNode('已押品'));
        iscollateral.style.float = 'right';
        iscollateral.style.background = '#FF9000';
        iscollateral.style.lineHeight = '28px';
        collateral.style.lineHeight = '28px';
        iscollateral.style.color = '#fff';
        iscollateral.style.fontSize = '12px';
        iscollateral.style.width = '65px';
        iscollateral.style.height = '30px';
        iscollateral.style.borderRadius = '6px 0 0 6px';
        collateral.style.borderRadius = '0 6px 6px 0';
        collateral.style.height = '30px';
        collateral.style.width = '65px';
        collateral.style.fontSize = '12px';
        collateral.style.color = '#fff';
        collateral.style.background = '#62CB31';
        collateral.style.float = 'right';
        message.style.position = 'absolute';
        message.style.width = '130px';
        message.style.height = '30px';
        message.style.background = '#fff';
        message.style.top = '-40px';
        message.style.left = '-18px';
        message.style.zIndex = '10';
        var sj = this._p = document.createElement("p");
        sj.style.position = "absolute";
        sj.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
        sj.style.width = 0;
        sj.style.height = 0;
        sj.style.borderLeft = "10px solid transparent";
        sj.style.borderRight = "10px solid transparent";
        sj.style.bottom = "-20px";
        sj.style.left = '26px';
        sj.style.borderTop = "10px solid #FF9000";
        message.appendChild(sj);
        message.appendChild(collateral);
        message.appendChild(iscollateral);
        div.appendChild(message);
        div.appendChild(img);
        iscollateral.onclick = function () {
            location.href = location.origin + '/estate/searchEstate?communityId=' + accountId + '&isEstate=true'+ '&city=' + $('#city').val();
        };
        collateral.onclick = function () {
            location.href = location.origin + '/estate/searchEstate?communityId=' + accountId + '&isEstate=false'+ '&city=' + $('#city').val();
        };
        img.onclick = function() {
            $(this).siblings('div').toggle();
        };

        map.getPanes().labelPane.appendChild(div);
        return div;
    };
    ComplexCustomOverlay.prototype.draw = function(){
        var map = this._map;
        var pixel = map.pointToOverlayPixel(this._point);
        this._div.style.left = pixel.x + 'px';
        this._div.style.top  = pixel.y + 'px';
    };
    myCompOverlay = new ComplexCustomOverlay(lineCenter,logo,cityName);
    map.addOverlay(myCompOverlay);

    //自定义边界线内覆盖物
    paramsData.forEach(function (Community) {
            //自定义小区覆盖物
        function ComplexCustomOverlay(point){
            this._point = point;
        }
        ComplexCustomOverlay.prototype = new BMap.Overlay();
        ComplexCustomOverlay.prototype.initialize = function(map){
            console.log('---->'+Community.isEstate)
            this._map = map;
            var div = this._div = document.createElement("div");
            var icon = document.createElement('img');
            if(Community.isEstate == 'true'){
                icon.src = '/assets/accountLogo/icon.png';
            }else{
                icon.src = '/assets/accountLogo/isicon.png';
            }
            icon.onclick = function () {
                location.href = location.origin + '/estate/searchEstate?buildingId=' + Community.buildingId + '&isEstate=' + Community.isEstate+ '&communityId=' + accountId;
            };
            div.appendChild(icon);
            div.style.position = "absolute";
            div.style.cursor = "pointer";
            map.getPanes().labelPane.appendChild(div);
            return div;
        };
        ComplexCustomOverlay.prototype.draw = function(){
            var map = this._map;
            var pixel = map.pointToOverlayPixel(this._point);
            this._div.style.left = pixel.x + "px";
            this._div.style.top  = pixel.y + "px";
        };
        var pt = new BMap.Point(Community.lng,Community.lat);
        myCompOverlay = new ComplexCustomOverlay(pt);
        map.addOverlay(myCompOverlay);
    });

    scrollFlag = true;
}
//网点省覆盖物
function createAccountProvince(mapDataList){
    mapDataList.forEach(function (data) {
        //自定义覆盖物
        function ComplexCustomOverlay(point, text,num){
            this._point = point;
            this._text = text;
            this._num = num;
        }
        ComplexCustomOverlay.prototype = new BMap.Overlay();
        ComplexCustomOverlay.prototype.initialize = function(map){
            this._map = map;
            var div = this._div = document.createElement("div");
            div.style.position = "absolute";
            div.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
            div.style.color = "white";
            div.style.height = "80px";
            div.style.width = "80px";
            div.style.lineHeight = "62px";
            div.style.opacity = '0.9';
            div.style.textAlign = "center";
            div.style.borderRadius = "50%";
            div.style.whiteSpace = "nowrap";
            div.style.MozUserSelect = "none";
            div.style.fontSize = "12px";
            div.style.cursor = "pointer";
            if(parseInt(this._num) < 300){
                div.style.backgroundColor = "#79ecd6";
            }else if(parseInt(this._num) >=300 && parseInt(this._num) < 500) {
                div.style.backgroundColor = "#4cdcc0";
            }else if(parseInt(this._num) >=500 && parseInt(this._num) < 700) {
                div.style.backgroundColor = "#33c3a7";
            }else {
                div.style.backgroundColor = "#26b095";
            }
            var span = this._span = document.createElement("span");
            div.appendChild(span);
            span.appendChild(document.createTextNode(this._text));
            //var that = this;
            var arrow = this._arrow = document.createElement("p");
            arrow.style.position = "absolute";
            arrow.style.width = "11px";
            arrow.style.height = "10px";
            arrow.style.top = "22px";
            arrow.style.left = "29%";
            div.appendChild(arrow);
            arrow.appendChild(document.createTextNode(this._num));
            var ply = [];
            var status;
            div.onmouseenter = function(){
                //pay = [];
                status = true;
                this.style.backgroundColor = "#e84a01";
                var bdary = new BMap.Boundary();

                bdary.get(data.name, function(rs){       //获取行政区域
                    //map.removeOverlay(ply);
                    var count = rs.boundaries.length; //行政区域的点有多少个
                    if (count === 0) {
                        alert('未能获取当前输入行政区域');
                        return ;
                    }
                    var pointArray = [];
                    for (var i = 0; i < count; i++) {
                        var p = new BMap.Polygon(rs.boundaries[i],  {strokeColor:"#e84a01", strokeWeight:4, strokeOpacity:0.0, fillOpacity: 0.0, fillColor: "none"}); //建立多边形覆盖物
                        if(status == true){
                            map.addOverlay(p);  //添加覆盖物
                        }

                        pointArray = pointArray.concat(p.getPath());
                        ply.push(p)
                    }
                });
            };
            div.onmouseleave = function(){
                if(parseInt(this.children[1].innerText) < 300){
                    div.style.backgroundColor = "#79ecd6";
                }else if(parseInt(this.children[1].innerText) >=300 && parseInt(this.children[1].innerText) < 500) {
                    div.style.backgroundColor = "#4cdcc0";
                }else if(parseInt(this.children[1].innerText) >=500 && parseInt(this.children[1].innerText) < 700) {
                    div.style.backgroundColor = "#33c3a7";
                }else {
                    div.style.backgroundColor = "#26b095";
                }
                status = false;
                var p;
                while(p = ply.pop()){
                    map.removeOverlay(p);
                }
            };
            div.onclick = function() {
                scrollFlag = false;
                flag = true;
                map.clearOverlays();
                var zone_number = {province:data.zoneNumber,level:2};
                RequestData(aroundAccountUrl,zone_number);
                if(allMapData.length==0 || mapDataStatus==false){
                    return
                }
                $("#city").val(data.zoneNumber);
                map.centerAndZoom(new BMap.Point(allMapData[0].lng, allMapData[0].lat),8);
                createAccountCity(allMapData);
            };

            map.getPanes().labelPane.appendChild(div);

            return div;
        };
        ComplexCustomOverlay.prototype.draw = function(){
            var map = this._map;
            var pixel = map.pointToOverlayPixel(this._point);
            this._div.style.left = pixel.x - parseInt(this._arrow.style.left) + "px";
            this._div.style.top  = pixel.y - 30 + "px";
        };
        var pt = new BMap.Point(data.lng,data.lat);
        var count = data.count + "个";
        myCompOverlay = new ComplexCustomOverlay(pt, data.name, count);
        map.addOverlay(myCompOverlay);
    });
    scrollFlag = true;
}
//网点市覆盖物
function createAccountCity(mapDataList){
    mapDataList.forEach(function (data) {
        //自定义覆盖物
        function ComplexCustomOverlay(point, text,num){
            this._point = point;
            this._text = text;
            this._num = num;
        }
        ComplexCustomOverlay.prototype = new BMap.Overlay();
        ComplexCustomOverlay.prototype.initialize = function(map){
            this._map = map;
            var div = this._div = document.createElement("div");
            div.style.position = "absolute";
            div.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
            div.style.color = "white";
            div.style.height = "80px";
            div.style.width = "80px";
            div.style.lineHeight = "62px";
            div.style.opacity = '0.9';
            div.style.textAlign = "center";
            div.style.borderRadius = "50%";
            div.style.whiteSpace = "nowrap";
            div.style.MozUserSelect = "none";
            div.style.fontSize = "12px";
            div.style.cursor = "pointer";
            if(parseInt(this._num) < 300){
                div.style.backgroundColor = "#79ecd6";
            }else if(parseInt(this._num) >=300 && parseInt(this._num) < 500) {
                div.style.backgroundColor = "#4cdcc0";
            }else if(parseInt(this._num) >=500 && parseInt(this._num) < 700) {
                div.style.backgroundColor = "#33c3a7";
            }else {
                div.style.backgroundColor = "#26b095";
            }
            var span = this._span = document.createElement("span");
            div.appendChild(span);
            span.appendChild(document.createTextNode(this._text));
            //var that = this;
            var arrow = this._arrow = document.createElement("p");
            arrow.style.position = "absolute";
            arrow.style.width = "11px";
            arrow.style.height = "10px";
            arrow.style.top = "22px";
            arrow.style.left = "29%";
            div.appendChild(arrow);
            arrow.appendChild(document.createTextNode(this._num));
            var ply = [];
            var status;
            div.onmouseenter = function(){
                //pay = [];
                status = true;
                this.style.backgroundColor = "#e84a01";
                var bdary = new BMap.Boundary();

                bdary.get(data.name, function(rs){       //获取行政区域
                    //map.removeOverlay(ply);
                    var count = rs.boundaries.length; //行政区域的点有多少个
                    if (count === 0) {
                        alert('未能获取当前输入行政区域');
                        return ;
                    }
                    var pointArray = [];
                    for (var i = 0; i < count; i++) {
                        var p = new BMap.Polygon(rs.boundaries[i],  {strokeColor:"#e84a01", strokeWeight:4, strokeOpacity:0.0, fillOpacity: 0.0, fillColor: "none"}); //建立多边形覆盖物
                        if(status == true){
                            map.addOverlay(p);  //添加覆盖物
                        }

                        pointArray = pointArray.concat(p.getPath());
                        ply.push(p)
                    }
                });
            };
            div.onmouseleave = function(){
                if(parseInt(this.children[1].innerText) < 300){
                    div.style.backgroundColor = "#79ecd6";
                }else if(parseInt(this.children[1].innerText) >=300 && parseInt(this.children[1].innerText) < 500) {
                    div.style.backgroundColor = "#4cdcc0";
                }else if(parseInt(this.children[1].innerText) >=500 && parseInt(this.children[1].innerText) < 700) {
                    div.style.backgroundColor = "#33c3a7";
                }else {
                    div.style.backgroundColor = "#26b095";
                }
                status = false;
                var p;
                while(p = ply.pop()){
                    map.removeOverlay(p);
                }
            };
            div.onclick = function() {
                scrollFlag = false;
                flag = true;
                map.clearOverlays();
                $("#city").val(data.zoneNumber);
                $("#s2id_city span:first").html(data.name);
                $("#city").change();
            };

            map.getPanes().labelPane.appendChild(div);

            return div;
        };
        ComplexCustomOverlay.prototype.draw = function(){
            var map = this._map;
            var pixel = map.pointToOverlayPixel(this._point);
            this._div.style.left = pixel.x - parseInt(this._arrow.style.left) + "px";
            this._div.style.top  = pixel.y - 30 + "px";
        };
        var pt = new BMap.Point(data.lng,data.lat);
        var count = data.count + "个";
        myCompOverlay = new ComplexCustomOverlay(pt, data.name, count);
        map.addOverlay(myCompOverlay);
    });
    scrollFlag = true;
}
//网点行政区覆盖物
function createAccountDistrict(mapDataList){
    mapDataList.forEach(function (data) {
        //自定义覆盖物
        function ComplexCustomOverlay(point, text,num){
            this._point = point;
            this._text = text;
            this._num = num;
        }
        ComplexCustomOverlay.prototype = new BMap.Overlay();
        ComplexCustomOverlay.prototype.initialize = function(map){
            this._map = map;
            var div = this._div = document.createElement("div");
            div.style.position = "absolute";
            div.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
            div.style.color = "white";
            div.style.height = "80px";
            div.style.width = "80px";
            div.style.lineHeight = "62px";
            div.style.opacity = '0.9';
            div.style.textAlign = "center";
            div.style.borderRadius = "50%";
            div.style.whiteSpace = "nowrap";
            div.style.MozUserSelect = "none";
            div.style.fontSize = "12px";
            div.style.cursor = "pointer";
            if(parseInt(this._num) < 300){
                div.style.backgroundColor = "#79ecd6";
            }else if(parseInt(this._num) >=300 && parseInt(this._num) < 500) {
                div.style.backgroundColor = "#4cdcc0";
            }else if(parseInt(this._num) >=500 && parseInt(this._num) < 700) {
                div.style.backgroundColor = "#33c3a7";
            }else {
                div.style.backgroundColor = "#26b095";
            }
            var span = this._span = document.createElement("span");
            div.appendChild(span);
            span.appendChild(document.createTextNode(this._text));
            //var that = this;
            var arrow = this._arrow = document.createElement("p");
            arrow.style.position = "absolute";
            arrow.style.width = "11px";
            arrow.style.height = "10px";
            arrow.style.top = "22px";
            arrow.style.left = "29%";
            div.appendChild(arrow);
            arrow.appendChild(document.createTextNode(this._num));
            var ply = [];
            var status;
            div.onmouseenter = function(){
                //pay = [];
                status = true;
                this.style.backgroundColor = "#e84a01";
                var bdary = new BMap.Boundary();

                bdary.get(data.name, function(rs){       //获取行政区域
                    //map.removeOverlay(ply);
                    var count = rs.boundaries.length; //行政区域的点有多少个
                    if (count === 0) {
                        alert('未能获取当前输入行政区域');
                        return ;
                    }
                    var pointArray = [];
                    for (var i = 0; i < count; i++) {
                        var p = new BMap.Polygon(rs.boundaries[i],  {strokeColor:"#e84a01", strokeWeight:4, strokeOpacity:0.0, fillOpacity: 0.0, fillColor: "none"}); //建立多边形覆盖物
                        if(status == true){
                            map.addOverlay(p);  //添加覆盖物
                        }

                        pointArray = pointArray.concat(p.getPath());
                        ply.push(p)
                    }
                });
            };
            div.onmouseleave = function(){
                if(parseInt(this.children[1].innerText) < 300){
                    div.style.backgroundColor = "#79ecd6";
                }else if(parseInt(this.children[1].innerText) >=300 && parseInt(this.children[1].innerText) < 500) {
                    div.style.backgroundColor = "#4cdcc0";
                }else if(parseInt(this.children[1].innerText) >=500 && parseInt(this.children[1].innerText) < 700) {
                    div.style.backgroundColor = "#33c3a7";
                }else {
                    div.style.backgroundColor = "#26b095";
                }
                status = false;
                var p;
                while(p = ply.pop()){
                    map.removeOverlay(p);
                }
            };
            div.onclick = function() {
                scrollFlag = false;
                flag = true;
                map.clearOverlays();
                var zone_number = {district:data.zoneNumber};
                RequestData(accountSearchUrl,zone_number);
                if(allMapData.length==0 || mapDataStatus==false){
                    return
                }
                map.centerAndZoom(new BMap.Point(allMapData[0].lng, allMapData[0].lat),16);
                createAccount(allMapData);
            };

            map.getPanes().labelPane.appendChild(div);

            return div;
        };
        ComplexCustomOverlay.prototype.draw = function(){
            var map = this._map;
            var pixel = map.pointToOverlayPixel(this._point);
            this._div.style.left = pixel.x - parseInt(this._arrow.style.left) + "px";
            this._div.style.top  = pixel.y - 30 + "px";
        };
        var pt = new BMap.Point(data.lng,data.lat);
        var count = data.count + "个";
        myCompOverlay = new ComplexCustomOverlay(pt, data.name, count);
        map.addOverlay(myCompOverlay);
    });
    scrollFlag = true;
}
//网点覆盖物
function createAccount(paramsData) {
    paramsData.forEach(function (Community,i) {
        //自定义小区覆盖物
        function ComplexCustomOverlay(point,text,num){
            this._point = point;
            this._text = text;
            this._num = num;
        }
        ComplexCustomOverlay.prototype = new BMap.Overlay();
        ComplexCustomOverlay.prototype.initialize = function(map){
            this._map = map;
            var div = this._div = document.createElement("div");
            div.style.backgroundImage = 'url(/assets/accountLogo/smallZhouBian.png)';
            div.appendChild(document.createTextNode(this._num));
            div.style.position = "absolute";
            div.style.width = '38px';
            div.style.height = '38px';
            div.style.lineHeight = '28px';
            div.style.textAlign = 'center';
            div.style.color = '#62CB31';
            div.style.fontSize = '15px';
            div.style.cursor = 'pointer';
            div.onclick = function() {
                scrollFlag = false;
                map.clearOverlays();
                var inputData = getInputData();
                inputData.accountId=Community.accountId;
                inputData.city=Community.zoneNumber;
                boundaryRequestData(accountCommunityUrl,inputData);
                map.centerAndZoom(new BMap.Point(Community.lng, Community.lat),19);
                var pt = new BMap.Point(Community.lng,Community.lat);
                createAccountCommunity(allMapData,boundaryData,pt,Community.logo,Community.accountName,Community.accountId);
            };

            map.getPanes().labelPane.appendChild(div);
            return div;
        };
        ComplexCustomOverlay.prototype.draw = function(){
            var map = this._map;
            var pixel = map.pointToOverlayPixel(this._point);
            this._div.style.left = pixel.x + 'px';
            this._div.style.top  = pixel.y + 'px';
        };
        var pt = new BMap.Point(Community.lng,Community.lat);
        myCompOverlay = new ComplexCustomOverlay(pt, Community.logo,i+1);
        map.addOverlay(myCompOverlay);
    });
    scrollFlag = true;
}
//网点小区覆盖物
function createAccountCommunity (paramsData,boundaryData,lineCenter,logo,cityName,accountId) {
    //自定义边界线和中心点图标
    boundaryData.forEach(function(data){
        var line = new BMap.Polygon(data.coordinates,  {strokeColor:"#e84a01", strokeWeight:4, strokeOpacity:0.0, fillOpacity: 0.0, fillColor: "none"}); //建立多边形覆盖物
        map.addOverlay(line);
    });
    function ComplexCustomOverlay(point,text,name){
        this._point = point;
        this._text = text;
        this._name = name;
    }
    ComplexCustomOverlay.prototype = new BMap.Overlay();
    ComplexCustomOverlay.prototype.initialize = function(map){
        this._map = map;
        var div = this._div = document.createElement("div");
        var img = document.createElement('img');
        img.src = '/assets/accountLogo/' + this._text;
        div.style.position = "absolute";
        div.style.cursor = 'pointer';
        div.style.zIndex = '1';
        var message = document.createElement('div');
        var cityNameD = document.createElement('div');
        cityNameD.appendChild(document.createTextNode(cityName));
        cityNameD.style.float = 'left';
        cityNameD.style.width = '130px';
        cityNameD.style.whiteSpace = 'normal';
        cityNameD.style.cursor = 'text';
        cityNameD.style.paddingLeft = '10px';
        cityNameD.style.height = '30px';
        cityNameD.style.overflow = 'hidden';
        cityNameD.style.color = '#333333';
        var collateral = document.createElement('div');
        var icon = document.createElement('img');
        icon.src = '/assets/accountLogo/isiconT.png';
        icon.style.padding = '0 4px 4px 4px';
        collateral.appendChild(icon);
        collateral.appendChild(document.createTextNode('未押品'));
        var iscollateral = document.createElement('div');
        var isicon = document.createElement('img');
        isicon.src = '/assets/accountLogo/iconT.png';
        isicon.style.padding = '0 4px 4px 4px';
        iscollateral.appendChild(isicon);
        iscollateral.appendChild(document.createTextNode('已押品'));
        iscollateral.style.float = 'right';
        iscollateral.style.background = '#FF9000';
        iscollateral.style.height = '28px';
        iscollateral.style.width = '65px';
        collateral.style.width = '65px';
        iscollateral.style.color = '#fff';
        collateral.style.color = '#fff';
        collateral.style.height = '28px';
        collateral.style.background = '#62CB31';
        collateral.style.float = 'right';
        message.style.position = 'absolute';
        message.style.width = '262px';
        message.style.height = '30px';
        message.style.border = '1px solid #62CB31';
        message.style.background = '#fff';
        message.style.borderRadius = '6px';
        message.style.top = '-38px';
        message.style.left = '-119px';
        message.style.zIndex = '10';
        message.style.fontSize = '12px';
        message.style.lineHeight = '28px';
        var sj = this._p = document.createElement("p");
        sj.style.position = "absolute";
        sj.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
        sj.style.width = 0;
        sj.style.height = 0;
        sj.style.borderLeft = "10px solid transparent";
        sj.style.borderRight = "10px solid transparent";
        sj.style.bottom = "-20px";
        sj.style.left = '126px';
        sj.style.borderTop = "10px solid #62CB31";
        message.appendChild(sj);
        message.appendChild(cityNameD);
        message.appendChild(collateral);
        message.appendChild(iscollateral);
        div.appendChild(message);
        div.appendChild(img);
        iscollateral.onclick = function () {
            location.href = location.origin + '/estate/searchEstate?accountId=' + accountId + '&isEstate=true';
        };
        collateral.onclick = function () {
            location.href = location.origin + '/estate/searchEstate?accountId=' + accountId + '&isEstate=false';
        };
        img.onclick = function() {
            /*scrollFlag = false;
            map.clearOverlays();
            var inputData = getInputData();
            inputData.accountId=Community.accountId;
            inputData.city=Community.zoneNumber;
            boundaryRequestData(accountCommunityUrl,inputData);
            map.centerAndZoom(new BMap.Point(Community.lng, Community.lat),19);
            var pt = new BMap.Point(Community.lng,Community.lat);
            createAccountCommunity(allMapData,boundaryData,pt,Community.logo);*/
            $(this).siblings('div').toggle();
        };

        map.getPanes().labelPane.appendChild(div);
        return div;
    };
    ComplexCustomOverlay.prototype.draw = function(){
        var map = this._map;
        var pixel = map.pointToOverlayPixel(this._point);
        this._div.style.left = pixel.x + 'px';
        this._div.style.top  = pixel.y + 'px';
    };
    myCompOverlay = new ComplexCustomOverlay(lineCenter,logo,cityName);
    map.addOverlay(myCompOverlay);

    //自定义边界线内覆盖物
    console.log(paramsData);
    paramsData.forEach(function (Community) {
        var houseList = Community.buildList;
        houseList.forEach(function(data){
            //自定义小区覆盖物
            data.forEach(function(list){
                function ComplexCustomOverlay(point){
                    this._point = point;
                }
                ComplexCustomOverlay.prototype = new BMap.Overlay();
                ComplexCustomOverlay.prototype.initialize = function(map){
                    this._map = map;
                    var div = this._div = document.createElement("div");
                    var icon = document.createElement('img');
                    if(list.isEstate == 'true'){
                        icon.src = '/assets/accountLogo/icon.png';
                    }else{
                        icon.src = '/assets/accountLogo/isicon.png';
                    }
                    icon.onclick = function () {
                        location.href = location.origin + '/estate/searchEstate?buildingId=' + list.buildingId ;
                    };
                    div.appendChild(icon);
                    div.style.position = "absolute";
                    div.style.cursor = "pointer";
                    map.getPanes().labelPane.appendChild(div);
                    return div;
                };
                ComplexCustomOverlay.prototype.draw = function(){
                    var map = this._map;
                    var pixel = map.pointToOverlayPixel(this._point);
                    this._div.style.left = pixel.x + "px";
                    this._div.style.top  = pixel.y + "px";
                };
                var pt = new BMap.Point(list.lng,list.lat);
                myCompOverlay = new ComplexCustomOverlay(pt);
                map.addOverlay(myCompOverlay);
                //createAccountBuilding(Community.buildList[0])
            })
        });
    });
    scrollFlag = true;
}
//网点楼栋覆盖物
function createAccountBuilding(paramsData){
    paramsData.forEach(function (searchEstate) {
        //自定义楼栋覆盖物
        function ComplexCustomOverlay(point,num){
            this._point = point;
            this._num = num;
        }
        ComplexCustomOverlay.prototype = new BMap.Overlay();
        ComplexCustomOverlay.prototype.initialize = function(map){
            this._map = map;
            var div = this._div = document.createElement("div");
            div.style.position = "absolute";
            div.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
            div.style.backgroundColor = "#26b095";
            div.style.color = "white";
            div.style.height = "30px";
            div.style.lineHeight = "18px";
            div.style.opacity = '0.9';
            div.style.textAlign = "center";
            div.style.borderRadius = "4px";
            div.style.whiteSpace = "nowrap";
            div.style.MozUserSelect = "none";
            div.style.fontSize = "12px";
            div.style.cursor = "pointer";
            div.style.padding = "6px";
            div.appendChild(document.createTextNode(this._num));
            var sj = this._p = document.createElement("p");
            sj.style.position = "absolute";
            sj.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
            sj.style.width = 0;
            sj.style.height = 0;
            sj.style.borderTop = "10px solid #26b095";
            sj.style.borderLeft = "10px solid transparent";
            sj.style.borderRight = "10px solid transparent";
            sj.style.bottom = "-20px";
            sj.style.left = "25%";
            div.appendChild(sj);
            div.onmouseenter = function(){
                this.style.backgroundColor = "#e84a01";
                sj.style.borderTop = "10px solid #e84a01";
            };
            div.onmouseleave = function(){
                this.style.backgroundColor = "#26b095";
                sj.style.borderTop = "10px solid #26b095";
            };
            var o = 0;
            var ul = document.createElement("div");
            div.onclick = function () {
                o++;
                $(this).siblings("div").children("div.hpanel").css("display","none");
                div.style.zIndex = "auto";
                $(this).siblings("div").css("zIndex","-10");
                if(o == 1){
                    ul.className = "hpanel";
                    ul.style.position = "absolute";
                    ul.style.top = "0";
                    ul.style.display = "block";
                    var body = document.createElement("div");
                    body.className = "panel-body list";
                    body.style.overflowY = "scroll";
                    var container = document.createElement("div");
                    container.className = "list-item-container";
                    container.style.maxHeight = "200px";
                    div.appendChild(ul);
                    body.appendChild(container);
                    ul.appendChild(body);
                    var allAreaResult = searchEstate.estateList;

                    allAreaResult.forEach(function(data){
                        data.forEach(function (data){
                            var item = document.createElement("div");
                            item.className = "list-item";
                            item.style.overflowX = "inherit";
                            var h3 = document.createElement("h3");
                            h3.className = "no-margins font-extra-bold text-success";
                            h3.style.fontSize = "12px";
                            if(data.cltv > 60 && data.cltv <= 80){
                                h3.style.color = "#FF9800";
                            }else if(data.cltv > 80 && data.cltv <= 100){
                                h3.style.color = "#E51C23";
                            }else if(data.cltv >= 100){
                                h3.style.color = "#8B1818";
                            }
                            h3.appendChild(document.createTextNode(data.sourceAddress));
                            item.appendChild(h3);
                            container.appendChild(item);
                            item.onclick = function () {
                                var href = window.location.origin + "/estate/mapShow/" + data.id;
                                window.open(href);
                            };
                        })
                    });
                    ul.style.left = div.offsetWidth + "px";
                }else if(ul.style.display == "block"){
                    ul.style.display = "none";
                }else{
                    ul.style.display = "block"
                }
                ul.onmouseenter = function () {
                    disableScroll(map);
                };
                ul.onmouseleave = function () {
                    endisableScroll(map);
                };
            };
            map.getPanes().labelPane.appendChild(div);
            return div;
        };
        ComplexCustomOverlay.prototype.draw = function(){
            var map = this._map;
            var pixel = map.pointToOverlayPixel(this._point);
            this._div.style.left = pixel.x + "px";
            this._div.style.top  = pixel.y + "px";
        };
        var pt = new BMap.Point(searchEstate.lng,searchEstate.lat);
        var areaResult = searchEstate.estateList[0].length + "笔";
        myCompOverlay = new ComplexCustomOverlay(pt, areaResult);
        map.addOverlay(myCompOverlay);
    });
    scrollFlag = true;
}
function disableScroll (map) {
    map.disableScrollWheelZoom();
}
function endisableScroll (map) {
    map.enableScrollWheelZoom();
}
//判断浏览区是否支持canvas
function isSupportCanvas(){
    var elem = document.createElement('canvas');
    return !!(elem.getContext && elem.getContext('2d'));
}
function setGradient(){
    /*格式如下所示:
   {
         0:'rgb(102, 255, 0)',
         .5:'rgb(255, 170, 0)',
         1:'rgb(255, 0, 0)'
   }*/
    var gradient = {};
    var colors = document.querySelectorAll("input[type='color']");
    colors = [].slice.call(colors,0);
    colors.forEach(function(ele){
        gradient[ele.getAttribute("data-key")] = ele.value;
    });
    heatmapOverlay.setOptions({"gradient":gradient});
}